#include"my_SList.h"
void SListTest01()
{
	//链表是由一个一个的节点组成，链表就全是节点
	//创建几个节点
	SLTNode* node1 = (SLTNode*)malloc(sizeof(SLTNode));
	node1->data = 1;

	SLTNode* node2 = (SLTNode*)malloc(sizeof(SLTNode));
	node2->data = 2;

	SLTNode* node3 = (SLTNode*)malloc(sizeof(SLTNode));
	node3->data = 3;

	SLTNode* node4 = (SLTNode*)malloc(sizeof(SLTNode));//给结构体指针开辟空间，结构体就出来了
	node4->data = 4;

	//将四个节点连接起来
	node1->next = node2;
	node2->next = node3;
	node3->next = node4;
	node4->next = NULL;

	//调用链表的打印
	SLTNode* plist = node1;
	SLTPrint(plist);
}

void SListTest02()
{
	//测试尾插
	SLTNode* plist = NULL;
	SLTPushBack(&plist, 1);
	SLTPushBack(&plist, 2);
	SLTPushBack(&plist, 3);
	SLTPrint(plist);

	//测试头插
	/*SLTPushFront(&plist, 0);
	SLTPrint(plist);
	plist = NULL;
	SLTPushFront(&plist, 0);
	SLTPrint(plist);
	SLTPushFront(&plist, 1);
	SLTPrint(plist);*/

	//测试尾删
	//SLTPopBack(&plist);
	//SLTPrint(plist);
	//SLTPopBack(&plist);
	//SLTPrint(plist);
	//SLTPopBack(&plist);
	//SLTPrint(plist);
	//SLTPopBack(plist);

	//测试头删
	//SLTPopFront(&plist);
	//SLTPrint(plist);
	//SLTPopFront(&plist);
	//SLTPrint(plist);
	//SLTPopFront(&plist);
	//SLTPrint(plist);
	//SLTPopFront(&plist);

	//测试在指定位置之前插入数据
	//SLTNode* find = SLTFind(plist, 1);
	//SLTInsert(&plist, find, 0);
	//SLTPrint(plist);
	//find = SLTFind(plist, 2);
	//SLTInsert(&plist, find, 11);
	//SLTPrint(plist);
	//find = SLTFind(plist, 3);
	//SLTInsert(&plist, find, 4);
	//SLTPrint(plist);
	//SLTInsert(NULL, find, 4);
	//plist = NULL;
	//SLTInsert(&plist, find, 4);

	//测试在指定位置之后插入数据
	//SLTNode* find = SLTFind(plist, 1);
	//SLTInsertAfter(find,5);
	//SLTPrint(plist);
	//find = SLTFind(plist, 3);
	//SLTInsertAfter(find, 4);
	//SLTPrint(plist);
	//find = SLTFind(plist, 2);
	//SLTInsertAfter(find, 11);
	//SLTPrint(plist);
	//SLTInsertAfter(NULL, 1);

	//测试删除pos节点
	//SLTNode* find = SLTFind(plist, 1);
	//SLTErase(&plist, find);
	//SLTPrint(plist);
	//find = SLTFind(plist, 3);
	//SLTErase(&plist, find);
	//SLTPrint(plist);
	//find = SLTFind(plist, 2);
	//SLTErase(&plist, find);
	//SLTPrint(plist);
	//SLTErase(&plist, NULL);

	//测试删除pos之后的一个节点
	//SLTNode* find = SLTFind(plist, 1);
	//SLTEraseAfter(find);
	//SLTPrint(plist);
	//find = SLTFind(plist, 1);
	//SLTEraseAfter(find);
	//SLTPrint(plist);
	//find = SLTFind(plist, 1);
	//SLTEraseAfter(find);

	SListDesTory(&plist);
	SListDesTory(&plist);
}


int main()
{
	//SListTest01();
	SListTest02();
	return 0;
}